package com.chenbei.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chenbei.system.domain.SysUserPost;
import com.chenbei.system.mapper.SysUserPostMapper;
import com.chenbei.system.service.ISysUserPostService;
import org.springframework.stereotype.Service;

@Service
public class SysUserPostService extends ServiceImpl<SysUserPostMapper, SysUserPost> implements ISysUserPostService {

    @Override
    public void addOrUpdate(SysUserPost sysUserPost) {
        LambdaQueryWrapper<SysUserPost> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(SysUserPost::getSysUserId, sysUserPost.getSysUserId());
        remove(lambdaQueryWrapper);

        if (sysUserPost.getPostId() != null) {
            save(sysUserPost);
        }
    }
}
